home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Tetris Light 1.0.3 / source / dialutil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-07  |  2.8 KB  |  82 lines  |  [TEXT/CWIE]

  1. /* ----------------------------------------------------------------------
  2. File: dialutil.c
  3.  
  4. Purpose:    This module provides routines useful for dialog processing.
  5.             
  6. Tetris Light - a simple implementation of a Tetris game
  7. Copyright © 1993-1996 Hoylen Sue
  8.  
  9. Updated for CW9 by Paul Celestin
  10. Questions about this version should go to me at celestin@celestin.com
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program; see the file COPYING.  If not, write to the
  24. Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  25. ---------------------------------------------------------------------- */
  26.  
  27. #include "local.h"
  28. #include "dialutil.h"
  29.  
  30. /*--------------------------------------------------------------------*/
  31.  
  32. static pascal void box_button(WindowPtr wind, INTEGER itemno)
  33. /* This is the display routine for the userItem which draws a solid
  34.    outline around the default button. */
  35. {
  36.     INTEGER    dummy;
  37.     Rect    rectangle;
  38.     Handle    handle;
  39.     
  40.     GetDItem(wind, itemno, &dummy, &handle, &rectangle);
  41.     PenSize(3, 3);
  42.     FrameRoundRect(&rectangle, 16, 16);
  43. }
  44.  
  45. /*--------------------------------------------------------------------*/
  46.  
  47. void install_hilight_button(DialogPtr dp, INTEGER button_item, INTEGER usr_item)
  48. /* This routine sets the given 'usr_item' to be a userItem whose role is
  49.    to draw the highlighting box around the default button in a dialog
  50.    box.  The rectangle of this user item is set to be around the 'button_item'
  51.    of the given dialog pointed to by 'dp'. */
  52. {
  53.     INTEGER    type;
  54.     Handle    hand;
  55.     Rect    rect;
  56.     
  57.     GetDialogItem(dp, button_item, &type, &hand, &rect);
  58.     InsetRect(&rect, -4, -4);
  59.     SetDialogItem(dp, usr_item, userItem + itemDisable, (Handle)box_button, &rect );
  60. }
  61.  
  62. /*--------------------------------------------------------------------*/
  63.  
  64. void simulate_key_hit(DialogPtr dp, INTEGER button_item)
  65. /* Flashes a push button control from the given dialog. This is a 
  66.    commonly used routine for indicating to the user that the button
  67.    has been hit when they used the keyboard equivalent for it. */
  68. {
  69.     LONGINT final;
  70.     Handle h;
  71.     Rect box;
  72.     INTEGER dummy;
  73.     
  74.     GetDItem(dp, button_item, &dummy, &h, &box);
  75.  
  76.     HiliteControl((ControlHandle)h, 1);
  77.     Delay(8, &final);        /* 8 ticks is sufficient */
  78.     HiliteControl((ControlHandle)h, 0);
  79. }
  80.  
  81. /*--------------------------------------------------------------------*/
  82.